package zj.chunan.db;


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @author user
 *
 */
public class DBconnection {
	/**
	 * ******************************************************
	 * DBConnection
	 * ******************************************************
	 * 
	 */
	public DBconnection() {
	
	}
	
	public Connection getConnection() {
		Connection con = null;
		try {
			//MySql
			Class.forName("com.mysql.jdbc.Driver");
		} catch (ClassNotFoundException ex) {
			ex.printStackTrace();
		}
		
		try {
			// URL
			String url = "jdbc:mysql://localhost:3306/temp_db"+ "?useUnicode=true&characterEncoding=GBK";
			// Connection
			con = DriverManager.getConnection(url, "root", "admin");
		} catch (SQLException ex1) {
			ex1.printStackTrace();
		}
			return con;
	}
	/**
	 * @param args
	 */
	public static void main(String args[]){
		DBconnection db = new DBconnection();
		System.out.println(db.getConnection().toString());
	}
}